﻿using System;
using System.Collections.Generic;

namespace Caramel.Web.Mvc.Validation.Conventions
{
	public class EmailPropertyConvention : IModelValidatorPropertyConvention
	{
		public void Apply(IEnumerable<Attribute> attributes, Type containerType, Func<object> modelAccessor, Type modelType, string propertyName, PropertyModelValidator instance)
		{
			//instance.
		}

		public bool Accept(IEnumerable<Attribute> attributes, Type containerType, Func<object> modelAccessor, Type modelType, string propertyName)
		{
			return
				propertyName.EndsWith("Email", StringComparison.InvariantCultureIgnoreCase) ||
				propertyName.EndsWith("EmailAddress", StringComparison.InvariantCultureIgnoreCase);
		}
	}
}
